from config import BASE_URL
from page.page_login import LoginPage
from script import log
from tools import DriverTools


class TestLogin(object):
    def setup_method(self):
        driver = DriverTools.get_driver()
        driver.get(BASE_URL+"/common/member/login#?type=1")
        self.log = LoginPage(driver)

    def teardown_method(self):
        # 关闭浏览器
        DriverTools.quit_driver()

    def test01_log_success(self):
        self.log.login("18683060000", "abc123")
        self.log.get_shot("login_success.png")
        print(self.log.get_success_result())
        log.info(f"执行结果：{self.log.get_success_result()}")
        assert "18683060000" in self.log.get_success_result()

    def test02_log_fail(self):
        self.log.login("1868306000", "abc123")
        print(self.log.get_error_result())
        log.info(f"执行结果：{self.log.get_success_result()}")
        assert "用户不存在" or "密码错误" in self.log.get_error_result()
        self.log.get_shot("login_fail01.png")

    def test03_log_fail(self):
        self.log.login("18683060000", "123456")
        print(self.log.get_error_result())
        log.info(f"执行结果：{self.log.get_success_result()}")
        assert "用户不存在" or "密码错误" in self.log.get_error_result()
        self.log.get_shot("login_fail02.png")
